<template>
  <avue-form v-model="examineForm"
             ref="examineForm"
             :option="examineOption"></avue-form>
</template>

<script>
export default {
  name: 'wf-exam-form',
  props: {
    process: {
      type: Object,
      default: () => {
        return {}
      }
    }
  },
  watch: {
    process: {
      handler(val) {
        if (!val) return
        if (val.hideComment) {
          this.findObject(this.examineOption.column, 'comment').display = false
        }
        if (val.hideCopy) {
          this.findObject(this.examineOption.column, '$copyUser').display = false
        }
        if (val.hideExamine) {
          this.findObject(this.examineOption.column, '$assignee').display = false
        }
        if (val.copyUser) {
          this.$set(this.examineForm, 'copyUser', val.copyUser)
        }
        if (val.copyUserName) {
          this.$set(this.examineForm, '$copyUser', val.copyUserName)
        }
      },
      deep: true,
      immediate: true
    }
  },
  data() {
    return {
      examineForm: {},
      examineOption: {
        menuBtn: false,
        column: [{
          label: '批复意见',
          prop: 'comment',
          type: 'textarea',
          span: 24,
          event: {
            change: (val) => {
              this.$emit('update:comment', val)
            }
          },
          display: true
        }, {
          label: '抄送人',
          prop: '$copyUser',
          placeholder: '请选择 抄送人',
          readonly: true,
          append: '+',
          span: 24,
          event: {
            click: () => {
              this.$emit('user-select', { type: 'copy', checkType: 'checkbox' })
            }
          },
          display: true
        }, {
          label: '指定审批人',
          prop: '$assignee',
          placeholder: '请选择 下一级审批人，如不选择则使用默认处理人，驳回时无效。多选时若下一节点为多实例则按选择顺序赋值，若不是择只有第一个生效。',
          readonly: true,
          append: '+',
          span: 24,
          event: {
            click: () => {
              this.$emit('user-select', { type: 'assignee', checkType: 'checkbox' })
            }
          },
          display: true
        }]
      },
    }
  },
  methods: {
    getComment() {
      return this.examineForm.comment
    }
  }
}
</script>

<style>
</style>